package com.cby.user.test3D;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/*
**  Create by: 王孙康宏
    Date:2021-10-24
    Time:22:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Instance {
    // 容器长宽高
    float l,w,h;
    // 初始物品（箱子）列表
    Box[] boxes;
    // 最小支撑率
    float supportRate;
    // 允许的最大交叉深度
    float dep;

    /**
     * 获取容器体积
     */
    public float getS(){
        return l*w*h;
    }
    public Instance(Instance instance){
        this.l = instance.getL();
        this.w = instance.getW();
        this.h = instance.getH();
        if(instance.getBoxes()!=null){
            this.boxes = copyBoxes(instance.getBoxes());
        }
        this.supportRate = instance.getSupportRate();
        this.dep = instance.getDep();
    }
    /**
     * 深拷贝Box对象数组
     */
    public Box[] copyBoxes(Box[] boxes){
        Box[] ret = new Box[boxes.length];
        for (int i = 0; i < boxes.length; i++) {
            ret[i] = new Box(boxes[i]);
        }
        return ret;
    }
}
